
from rest_framework import serializers
# contrib模块：是别的人/团队写的django模块，而django团队认为写的很好，所以就被django收录了
from django.contrib.auth.models import Permission,ContentType

# 新增权限可选类型
class PermTypeModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = ContentType
        fields = [
            'id',
            'name'
        ]

# Permission权限序列化器
class PermModelSerializer(serializers.ModelSerializer):

    class Meta:
        model = Permission
        fields = [
            'id',
            'name',
            'codename',
            'content_type' # 该字段在发序列化接收前端传来的关联对象主键值
        ]